package com.gxa.accommodation.controller;

import com.gxa.accommodation.dto.AccommodationRoomTypeDTO;
import com.gxa.accommodation.service.AccommodationRoomTypeService;
import com.gxa.common.base.RespResult;
import com.gxa.common.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * 房间类型控制类
 */
@RestController
@RequestMapping("/accommodationRoomType")
public class AccommodationRoomTypeController {

    @Autowired
    private AccommodationRoomTypeService service;

    /**
     * 添加房间类型
     * @param accommodationRoomTypeDTO
     * @return
     */
    @PostMapping("/addRoomType")
    public RespResult addRoomType(@Validated @RequestBody AccommodationRoomTypeDTO accommodationRoomTypeDTO){
        return service.addRoomType(accommodationRoomTypeDTO);
    }

    /**
     * 上传图片
     * @param file
     * @param id
     * @param request
     * @return
     */
    @PostMapping("/uploadRoomTypeImg")
    public RespResult uploadRoomTypeImg(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id,HttpServletRequest request){
        return service.addRoomTypeImg(file,id,request);
    }

    /**
     * 查询所有房间类型列表
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/showRoomTypeList")
    public RespResult showRoomTypeList(Integer currentPage,Integer pageSize){
        return service.showRoomTypeList(currentPage,pageSize);
    }

    /**
     * 更新房间类型
     * @param accommodationRoomTypeDTO
     * @return
     */
    @PostMapping("/updateRoomType")
    public RespResult updateRoomType(@Validated @RequestBody AccommodationRoomTypeDTO accommodationRoomTypeDTO){
        return service.updateRoomType(accommodationRoomTypeDTO);
    }

    @PostMapping("/updateRoomStatusById")
    public RespResult updateRoomStatusById(Long id,Byte roomStatus){
        return service.updateRoomStatusById(id,roomStatus);
    }


    @PostMapping("/delRoomTypeById")
    public RespResult delRoomTypeById(Long id){
        return service.delRoomTypeById(id);
    }



}
